package com.fz.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fz.entity.Fee;
import com.fz.service.FeeService;
import com.fz.vo.ResultVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
 * <p>
 * 存储水电使用账单信息 前端控制器
 * </p>
 *
 * @author hyr
 * @since 2025-06-22
 */
@RestController
@RequestMapping("/fee")
public class FeeController {
    @Resource
    private FeeService feeService;

    // 分页查询
    @GetMapping("/list")
    public ResultVo<Page<Fee>> list(@RequestParam(defaultValue = "1") Integer pageNo,
                                    @RequestParam(defaultValue = "10") Integer pageSize,
                                    Long userId, Integer type) {
        return ResultVo.success(feeService.listByPage(pageNo, pageSize, userId, type));
    }

    // 获取每日用量统计
    @GetMapping("/dailyConsumption")
    public ResultVo<List<Map<String, Object>>> dailyConsumption(Long userId) {
        return ResultVo.success(feeService.getDailyConsumption(userId));
    }

    // 获取费用类型分布
    @GetMapping("/feeDistribution")
    public ResultVo<List<Map<String, Object>>> feeDistribution(Long userId) {
        return ResultVo.success(feeService.getFeeDistribution(userId));
    }
}
